package me.thinkjet.controller;

import com.jfinal.core.Controller;
import com.jfinal.ext.render.DwzRender;
import com.jfinal.ext.route.ControllerBind;
import com.jfinal.plugin.activerecord.Page;
import me.thinkjet.auth.AuthManager;
import me.thinkjet.model.Activity;
import me.thinkjet.model.ActivityApply;
import me.thinkjet.service.TagService;
import me.thinkjet.service.UserService;

@ControllerBind(controllerKey = "/activity_apply", viewPath = "activity_apply")
public class ActivityApplyController extends Controller {

	public void index() {
		int page = getParaToInt("pageNum", 1);
		int numPerPage = getParaToInt("numPerPage", 20);
		Page<Activity> activities = Activity.dao.paginate(page, numPerPage, "select *", "from activity");
		setAttr("activitylist", activities);
	}

	public void show() {
		int page = getParaToInt("pageNum", 1);
		long activity_id = getParaToLong("activity_id");
		int numPerPage = getParaToInt("numPerPage", 20);
		Page<ActivityApply> activityapply = ActivityApply.dao.paginate(page, numPerPage,
				"select apply.*,user.username",
				"from activity_apply apply left join users user on user.id=apply.user_id" +
						" where apply.activity_id=?", activity_id);
		setAttr("activityapply", activityapply);
		setAttr("activity",Activity.dao.findById(activity_id));
	}
}
